/**

This file is part of MaCI/GIMnet.

MaCI/GIMnet is free software: you can redistribute it and/or modify it 
under the terms of the GNU Lesser General Public License as published 
by the Free Software Foundation, either version 3 of the License, or 
(at your option) any later version.

MaCI/GIMnet is distributed in the hope that it will be useful, but WITHOUT 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public 
License for more details.

You should have received a copy of the GNU Lesser General Public 
License along with GIMnet. (See COPYING.LESSER) If not, see 
<http://www.gnu.org/licenses/>.

**/
#ifndef JCMACISPEEDCONTROL_H
#define JCMACISPEEDCONTROL_H

#include "JoystickControlComponent.h"

#include "SpeedCtrlClient.hpp"
#include <wx/stattext.h>

// Identification id:s for axis/button options.
// Options must not be negative!
// Axes and buttons have separate id-systems so they can overlap.
#define SPEEDCTRL_STEERINGJOYSTICK_AXIS   0
#define SPEEDCTRL_GASBRAKEJOYSTICK_AXIS   1
#define SPEEDCTRL_STEERING_WHEEL_AXIS     2
#define SPEEDCTRL_GASBRAKEPEDAL_AXIS      3
#define SPEEDCTRL_GASPEDAL_AXIS           4

#define SPEEDCTRL_HANDBRAKE_BUTTON        0
#define SPEEDCTRL_GEARUP_BUTTON           1
#define SPEEDCTRL_GEARDOWN_BUTTON         2
#define SPEEDCTRL_ACCUP_BUTTON            3
#define SPEEDCTRL_ACCDOWN_BUTTON          4


#define MSC_NAME                  "MaCI SpeedCtrl"

class JCMaCISpeedCtrl : public JoystickControlComponent
{
  public:
    JCMaCISpeedCtrl(gimi::GIMI *aGIMIPtr,
                    wxSizer *compSizer,
		    wxPanel *aComponentPanel);
    virtual ~JCMaCISpeedCtrl();
    
    virtual bool startComponent();
    
    virtual int addTarget(const gimi::GIMIService &aTarget);
    
 private:
    static void commandSenderThread(void *p);
    
    MaCI::SpeedCtrl::CSpeedCtrlClient *iSpeedCtrlClient;

  
     float iVehicleMaxSpeed;
    float iVehicleMinSpeed;
    float iVehicleMaxAngularSpeed;
    float iVehicleMaxAcceleration;
    ownThreadHandle iCommandThread;
    
    wxStaticText* textSpeedText;
    wxStaticText* textSpeedValue;
    
    wxStaticText* textAngularSpeedText;
    wxStaticText* textAngularSpeedValue;
     
    wxStaticText* textAccText;
    wxStaticText* textAccValue;
    
    wxStaticText* textBrakeText;
    wxStaticText* textBrakeValue;
    
    wxStaticText* textGearText;
    wxStaticText* textGearValue;
    
    wxStaticText* textCurrentSpeedText;
    wxStaticText* textCurrentSpeedValue;
    
    wxStaticText* textCurrentAngularSpeedText;
    wxStaticText* textCurrentAngularSpeedValue;

    wxStaticText* textCurrentAccelerationText;
    wxStaticText* textCurrentAccelerationValue;

    gimi::GIMIService iTarget;
};

#endif //  JCMACISPEEDCONTROL_H
